A, B, C = map(int, input().split())
if A > B:
    A ^= B
    B ^= A
    A ^= B
if A > C:
    A ^= C
    C ^= A
    A ^= C
if C < B:
    C ^= B
    B ^= C
    C ^= B
ABC = input()
for i in ABC:
    if i == "A":
        print(A,end=" ")
    if i == "B":
        print(B, end=" ")
    if i == "C":
        print(C, end=" ")
